package cn.tedu.lbs.article.web.controller;

import cn.tedu.lbs.article.web.service.ArticleService;
import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.pojo.content.param.ArticleActionParam;
import com.tarena.lbs.pojo.content.vo.ArticleActionPageResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;

@RestController
@Slf4j
public class ActionController {
    @Autowired
    private ArticleService articleService;
    //用户点赞 收藏提交接口
    @PostMapping("/admin/content/article/behavior")
    public Result<Void> behave(ArticleActionParam articleActionParam)
        throws BusinessException {
        articleService.behave(articleActionParam);
        return Result.success();
    }
    //查询用户曾经操作过的文章
    @GetMapping("/admin/content/article/getBehaviorList")
    public Result<ArticleActionPageResultVO>  getBehaveList()
            throws BusinessException, ExecutionException, InterruptedException {
        long start=System.currentTimeMillis();
        ArticleActionPageResultVO behaveList = articleService.getBehaveList();
        long end=System.currentTimeMillis();
        log.info("查询用户曾经操作过的文章总耗时:{}MS",end-start);
        return new Result<>(behaveList);
    }

}
